<extend name="common:commonTemplate" />
<block name="main_content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="index.html"
				data-original-title="Go to Home"><i class="icon-home"></i> 首页</a>
			<a href="#">权限管理</a> <a class="current" href="#">密码修改</a>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i>
						</span>
						<h5>搜索条件</h5>
					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate" id="basic_validate"
							name="basic_validate" action="#" method="post"
							class="form-horizontal">
							<div class="control-group">
								<label class="control-label">用户名：</label>
								<div class="controls">
									<input type="text" id="uname" name="uname" value="{$user_id}">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">原密码：</label>
								<div class="controls">
									<input type="password" id="originalpass" name="originalpass">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">新密码：</label>
								<div class="controls">
									<input type="password" id="newpass" name="newpass">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label">确认密码：</label>
								<div class="controls">
									<input type="password" id="confirmpass" name="confirmpass">
								</div>
							</div>
							<div class="form-actions">
								<input type="button" class="btn btn-success" value="重置" onclick="updatePassword()">
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
</div>
</block>

<block name="js_content">
<script>
	 function updatePassword(){
	 	var uname = $('#uname').val();
		var originalpass = $('#originalpass').val();
		if(originalpass =='' ){
			alert("原密码不能为空");
			return;
		}
		var newpass = $('#newpass').val();
		if(newpass =='' ){
			alert("新密码不能为空");
			return;
		}
		var confirmpass = $('#confirmpass').val();
		if(confirmpass ==''){
			alert("确认密码不能为空");
			return;
		}
		var result = AuthService.resetPassword(uname,originalpass,newpass,confirmpass);
		if (result.IsSuccess == 0) {
			alert(result.ErrorMsg);
			return;
		} else {
			if(result.Result !=null){
				alert(result.Result);
				if(result.Result=='密码修改成功'){
					AdminService.Logout(user_id);
					window.location.href =ServerConfig.AdminConfig.login_page;
				}
			}
		}
	 }
</script>
</block>

